package com.thiswhyme.openfeign.server.api;

import com.thiswhyme.common.response.ResponseVo;
import com.thiswhyme.openfeign.gson.adapter.requestparam.RequestParamConverter;
import com.thiswhyme.openfeign.server.api.dto.BaseDto;
import com.thiswhyme.openfeign.server.api.dto.Status;
import com.thiswhyme.openfeign.server.api.dto.StudentDto;
import org.springframework.web.bind.annotation.*;

/**
 * Created by thiswhyme on 2020/8/15.
 */
@RestController
@RequestMapping("/user/")
public class UserController {

    @PostMapping("user-list")
    public ResponseVo<BaseDto> listUsers(@RequestBody BaseDto req) {
        return ResponseVo.success(req);
    }

    @PostMapping("user-list2")
    public ResponseVo<BaseDto> listUsers(@RequestBody BaseDto req, @RequestParam Long id) {
        req.setId(id);
        return ResponseVo.success(req);
    }

    @PostMapping("user-info")
    public ResponseVo<BaseDto> queryUserInfo(@RequestParamConverter @RequestParam("student") StudentDto student) {
        return ResponseVo.success(student);
    }

    @GetMapping("user-status")
    public ResponseVo<Status> queryUserStatus(@RequestParam("status") Status status) throws InterruptedException {
        Thread.sleep(2000);
        return ResponseVo.success(status);
    }
}
